package registnet.dao;


import java.math.BigDecimal;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Date;
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang.ObjectUtils;
import org.apache.torque.TorqueException;
import org.apache.torque.om.BaseObject;
import org.apache.torque.om.ComboKey;
import org.apache.torque.om.DateKey;
import org.apache.torque.om.NumberKey;
import org.apache.torque.om.ObjectKey;
import org.apache.torque.om.SimpleKey;
import org.apache.torque.om.StringKey;
import org.apache.torque.om.Persistent;
import org.apache.torque.util.Criteria;
import org.apache.torque.util.Transaction;

  
  
/**
 * This class was autogenerated by Torque on:
 *
 * [Tue Jun 30 14:38:16 PDT 2009]
 *
 * You should not use this class directly.  It should not even be
 * extended all references should be to Section
 */
public abstract class BaseSection extends BaseObject
{
    /** The Peer class */
    private static final SectionPeer peer =
        new SectionPeer();

        
    /** The value for the sectionId field */
    private int sectionId;
      
    /** The value for the sectionConfigurationId field */
    private int sectionConfigurationId;
      
    /** The value for the sectionName field */
    private String sectionName;
      
    /** The value for the laboratoryDay field */
    private String laboratoryDay;
      
    /** The value for the lectureDay field */
    private String lectureDay;
      
    /** The value for the recitationDay field */
    private String recitationDay;
      
    /** The value for the laboratoryRoom field */
    private String laboratoryRoom;
      
    /** The value for the lectureRoom field */
    private String lectureRoom;
      
    /** The value for the recitationRoom field */
    private String recitationRoom;
      
    /** The value for the laboratoryTime field */
    private String laboratoryTime;
      
    /** The value for the lectureTime field */
    private String lectureTime;
      
    /** The value for the recitationTime field */
    private String recitationTime;
      
    /** The value for the laboratoryInstructor field */
    private String laboratoryInstructor;
      
    /** The value for the lectureInstructor field */
    private String lectureInstructor;
      
    /** The value for the recitationInstructor field */
    private String recitationInstructor;
      
    /** The value for the studentCount field */
    private int studentCount;
      
    /** The value for the isTeamTeach field */
    private int isTeamTeach;
  
    
    /**
     * Get the SectionId
     *
     * @return int
     */
    public int getSectionId()
    {
        return sectionId;
    }

                        
    /**
     * Set the value of SectionId
     *
     * @param v new value
     */
    public void setSectionId(int v) 
    {
    
                  if (this.sectionId != v)
              {
            this.sectionId = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the SectionConfigurationId
     *
     * @return int
     */
    public int getSectionConfigurationId()
    {
        return sectionConfigurationId;
    }

                              
    /**
     * Set the value of SectionConfigurationId
     *
     * @param v new value
     */
    public void setSectionConfigurationId(int v) throws TorqueException
    {
    
                  if (this.sectionConfigurationId != v)
              {
            this.sectionConfigurationId = v;
            setModified(true);
        }
    
                          
                if (aSectionConfiguration != null && !(aSectionConfiguration.getSectionConfigurationId() == v))
                {
            aSectionConfiguration = null;
        }
      
              }
  
    /**
     * Get the SectionName
     *
     * @return String
     */
    public String getSectionName()
    {
        return sectionName;
    }

                        
    /**
     * Set the value of SectionName
     *
     * @param v new value
     */
    public void setSectionName(String v) 
    {
    
                  if (!ObjectUtils.equals(this.sectionName, v))
              {
            this.sectionName = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the LaboratoryDay
     *
     * @return String
     */
    public String getLaboratoryDay()
    {
        return laboratoryDay;
    }

                        
    /**
     * Set the value of LaboratoryDay
     *
     * @param v new value
     */
    public void setLaboratoryDay(String v) 
    {
    
                  if (!ObjectUtils.equals(this.laboratoryDay, v))
              {
            this.laboratoryDay = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the LectureDay
     *
     * @return String
     */
    public String getLectureDay()
    {
        return lectureDay;
    }

                        
    /**
     * Set the value of LectureDay
     *
     * @param v new value
     */
    public void setLectureDay(String v) 
    {
    
                  if (!ObjectUtils.equals(this.lectureDay, v))
              {
            this.lectureDay = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the RecitationDay
     *
     * @return String
     */
    public String getRecitationDay()
    {
        return recitationDay;
    }

                        
    /**
     * Set the value of RecitationDay
     *
     * @param v new value
     */
    public void setRecitationDay(String v) 
    {
    
                  if (!ObjectUtils.equals(this.recitationDay, v))
              {
            this.recitationDay = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the LaboratoryRoom
     *
     * @return String
     */
    public String getLaboratoryRoom()
    {
        return laboratoryRoom;
    }

                        
    /**
     * Set the value of LaboratoryRoom
     *
     * @param v new value
     */
    public void setLaboratoryRoom(String v) 
    {
    
                  if (!ObjectUtils.equals(this.laboratoryRoom, v))
              {
            this.laboratoryRoom = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the LectureRoom
     *
     * @return String
     */
    public String getLectureRoom()
    {
        return lectureRoom;
    }

                        
    /**
     * Set the value of LectureRoom
     *
     * @param v new value
     */
    public void setLectureRoom(String v) 
    {
    
                  if (!ObjectUtils.equals(this.lectureRoom, v))
              {
            this.lectureRoom = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the RecitationRoom
     *
     * @return String
     */
    public String getRecitationRoom()
    {
        return recitationRoom;
    }

                        
    /**
     * Set the value of RecitationRoom
     *
     * @param v new value
     */
    public void setRecitationRoom(String v) 
    {
    
                  if (!ObjectUtils.equals(this.recitationRoom, v))
              {
            this.recitationRoom = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the LaboratoryTime
     *
     * @return String
     */
    public String getLaboratoryTime()
    {
        return laboratoryTime;
    }

                        
    /**
     * Set the value of LaboratoryTime
     *
     * @param v new value
     */
    public void setLaboratoryTime(String v) 
    {
    
                  if (!ObjectUtils.equals(this.laboratoryTime, v))
              {
            this.laboratoryTime = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the LectureTime
     *
     * @return String
     */
    public String getLectureTime()
    {
        return lectureTime;
    }

                        
    /**
     * Set the value of LectureTime
     *
     * @param v new value
     */
    public void setLectureTime(String v) 
    {
    
                  if (!ObjectUtils.equals(this.lectureTime, v))
              {
            this.lectureTime = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the RecitationTime
     *
     * @return String
     */
    public String getRecitationTime()
    {
        return recitationTime;
    }

                        
    /**
     * Set the value of RecitationTime
     *
     * @param v new value
     */
    public void setRecitationTime(String v) 
    {
    
                  if (!ObjectUtils.equals(this.recitationTime, v))
              {
            this.recitationTime = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the LaboratoryInstructor
     *
     * @return String
     */
    public String getLaboratoryInstructor()
    {
        return laboratoryInstructor;
    }

                        
    /**
     * Set the value of LaboratoryInstructor
     *
     * @param v new value
     */
    public void setLaboratoryInstructor(String v) 
    {
    
                  if (!ObjectUtils.equals(this.laboratoryInstructor, v))
              {
            this.laboratoryInstructor = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the LectureInstructor
     *
     * @return String
     */
    public String getLectureInstructor()
    {
        return lectureInstructor;
    }

                        
    /**
     * Set the value of LectureInstructor
     *
     * @param v new value
     */
    public void setLectureInstructor(String v) 
    {
    
                  if (!ObjectUtils.equals(this.lectureInstructor, v))
              {
            this.lectureInstructor = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the RecitationInstructor
     *
     * @return String
     */
    public String getRecitationInstructor()
    {
        return recitationInstructor;
    }

                        
    /**
     * Set the value of RecitationInstructor
     *
     * @param v new value
     */
    public void setRecitationInstructor(String v) 
    {
    
                  if (!ObjectUtils.equals(this.recitationInstructor, v))
              {
            this.recitationInstructor = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the StudentCount
     *
     * @return int
     */
    public int getStudentCount()
    {
        return studentCount;
    }

                        
    /**
     * Set the value of StudentCount
     *
     * @param v new value
     */
    public void setStudentCount(int v) 
    {
    
                  if (this.studentCount != v)
              {
            this.studentCount = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the IsTeamTeach
     *
     * @return int
     */
    public int getIsTeamTeach()
    {
        return isTeamTeach;
    }

                        
    /**
     * Set the value of IsTeamTeach
     *
     * @param v new value
     */
    public void setIsTeamTeach(int v) 
    {
    
                  if (this.isTeamTeach != v)
              {
            this.isTeamTeach = v;
            setModified(true);
        }
    
          
              }
  
      
    
                  
    
        private SectionConfiguration aSectionConfiguration;

    /**
     * Declares an association between this object and a SectionConfiguration object
     *
     * @param v SectionConfiguration
     * @throws TorqueException
     */
    public void setSectionConfiguration(SectionConfiguration v) throws TorqueException
    {
            if (v == null)
        {
                    setSectionConfigurationId(0);
                  }
        else
        {
            setSectionConfigurationId(v.getSectionConfigurationId());
        }
                aSectionConfiguration = v;
    }

                                            
    /**
     * Get the associated SectionConfiguration object
     *
     * @return the associated SectionConfiguration object
     * @throws TorqueException
     */
    public SectionConfiguration getSectionConfiguration() throws TorqueException
    {
        if (aSectionConfiguration == null && (this.sectionConfigurationId > 0))
        {
                          aSectionConfiguration = SectionConfigurationPeer.retrieveByPK(SimpleKey.keyFor(this.sectionConfigurationId));
              
            /* The following can be used instead of the line above to
               guarantee the related object contains a reference
               to this object, but this level of coupling
               may be undesirable in many circumstances.
               As it can lead to a db query with many results that may
               never be used.
               SectionConfiguration obj = SectionConfigurationPeer.retrieveByPK(this.sectionConfigurationId);
               obj.addSections(this);
            */
        }
        return aSectionConfiguration;
    }

    /**
     * Provides convenient way to set a relationship based on a
     * ObjectKey.  e.g.
     * <code>bar.setFooKey(foo.getPrimaryKey())</code>
     *
           */
    public void setSectionConfigurationKey(ObjectKey key) throws TorqueException
    {
      
                        setSectionConfigurationId(((NumberKey) key).intValue());
                  }
       
                
    private static List fieldNames = null;

    /**
     * Generate a list of field names.
     *
     * @return a list of field names
     */
    public static synchronized List getFieldNames()
    {
        if (fieldNames == null)
        {
            fieldNames = new ArrayList();
              fieldNames.add("SectionId");
              fieldNames.add("SectionConfigurationId");
              fieldNames.add("SectionName");
              fieldNames.add("LaboratoryDay");
              fieldNames.add("LectureDay");
              fieldNames.add("RecitationDay");
              fieldNames.add("LaboratoryRoom");
              fieldNames.add("LectureRoom");
              fieldNames.add("RecitationRoom");
              fieldNames.add("LaboratoryTime");
              fieldNames.add("LectureTime");
              fieldNames.add("RecitationTime");
              fieldNames.add("LaboratoryInstructor");
              fieldNames.add("LectureInstructor");
              fieldNames.add("RecitationInstructor");
              fieldNames.add("StudentCount");
              fieldNames.add("IsTeamTeach");
              fieldNames = Collections.unmodifiableList(fieldNames);
        }
        return fieldNames;
    }

    /**
     * Retrieves a field from the object by name passed in as a String.
     *
     * @param name field name
     * @return value
     */
    public Object getByName(String name)
    {
          if (name.equals("SectionId"))
        {
                return new Integer(getSectionId());
            }
          if (name.equals("SectionConfigurationId"))
        {
                return new Integer(getSectionConfigurationId());
            }
          if (name.equals("SectionName"))
        {
                return getSectionName();
            }
          if (name.equals("LaboratoryDay"))
        {
                return getLaboratoryDay();
            }
          if (name.equals("LectureDay"))
        {
                return getLectureDay();
            }
          if (name.equals("RecitationDay"))
        {
                return getRecitationDay();
            }
          if (name.equals("LaboratoryRoom"))
        {
                return getLaboratoryRoom();
            }
          if (name.equals("LectureRoom"))
        {
                return getLectureRoom();
            }
          if (name.equals("RecitationRoom"))
        {
                return getRecitationRoom();
            }
          if (name.equals("LaboratoryTime"))
        {
                return getLaboratoryTime();
            }
          if (name.equals("LectureTime"))
        {
                return getLectureTime();
            }
          if (name.equals("RecitationTime"))
        {
                return getRecitationTime();
            }
          if (name.equals("LaboratoryInstructor"))
        {
                return getLaboratoryInstructor();
            }
          if (name.equals("LectureInstructor"))
        {
                return getLectureInstructor();
            }
          if (name.equals("RecitationInstructor"))
        {
                return getRecitationInstructor();
            }
          if (name.equals("StudentCount"))
        {
                return new Integer(getStudentCount());
            }
          if (name.equals("IsTeamTeach"))
        {
                return new Integer(getIsTeamTeach());
            }
          return null;
    }
    
    /**
     * Retrieves a field from the object by name passed in
     * as a String.  The String must be one of the static
     * Strings defined in this Class' Peer.
     *
     * @param name peer name
     * @return value
     */
    public Object getByPeerName(String name)
    {
          if (name.equals(SectionPeer.SECTIONID))
        {
                return new Integer(getSectionId());
            }
          if (name.equals(SectionPeer.SECTIONCONFIGURATIONID))
        {
                return new Integer(getSectionConfigurationId());
            }
          if (name.equals(SectionPeer.SECTIONNAME))
        {
                return getSectionName();
            }
          if (name.equals(SectionPeer.LABORATORYDAY))
        {
                return getLaboratoryDay();
            }
          if (name.equals(SectionPeer.LECTUREDAY))
        {
                return getLectureDay();
            }
          if (name.equals(SectionPeer.RECITATIONDAY))
        {
                return getRecitationDay();
            }
          if (name.equals(SectionPeer.LABORATORYROOM))
        {
                return getLaboratoryRoom();
            }
          if (name.equals(SectionPeer.LECTUREROOM))
        {
                return getLectureRoom();
            }
          if (name.equals(SectionPeer.RECITATIONROOM))
        {
                return getRecitationRoom();
            }
          if (name.equals(SectionPeer.LABORATORYTIME))
        {
                return getLaboratoryTime();
            }
          if (name.equals(SectionPeer.LECTURETIME))
        {
                return getLectureTime();
            }
          if (name.equals(SectionPeer.RECITATIONTIME))
        {
                return getRecitationTime();
            }
          if (name.equals(SectionPeer.LABORATORYINSTRUCTOR))
        {
                return getLaboratoryInstructor();
            }
          if (name.equals(SectionPeer.LECTUREINSTRUCTOR))
        {
                return getLectureInstructor();
            }
          if (name.equals(SectionPeer.RECITATIONINSTRUCTOR))
        {
                return getRecitationInstructor();
            }
          if (name.equals(SectionPeer.STUDENTCOUNT))
        {
                return new Integer(getStudentCount());
            }
          if (name.equals(SectionPeer.ISTEAMTEACH))
        {
                return new Integer(getIsTeamTeach());
            }
          return null;
    }

    /**
     * Retrieves a field from the object by Position as specified
     * in the xml schema.  Zero-based.
     *
     * @param pos position in xml schema
     * @return value
     */
    public Object getByPosition(int pos)
    {
            if (pos == 0)
        {
                return new Integer(getSectionId());
            }
              if (pos == 1)
        {
                return new Integer(getSectionConfigurationId());
            }
              if (pos == 2)
        {
                return getSectionName();
            }
              if (pos == 3)
        {
                return getLaboratoryDay();
            }
              if (pos == 4)
        {
                return getLectureDay();
            }
              if (pos == 5)
        {
                return getRecitationDay();
            }
              if (pos == 6)
        {
                return getLaboratoryRoom();
            }
              if (pos == 7)
        {
                return getLectureRoom();
            }
              if (pos == 8)
        {
                return getRecitationRoom();
            }
              if (pos == 9)
        {
                return getLaboratoryTime();
            }
              if (pos == 10)
        {
                return getLectureTime();
            }
              if (pos == 11)
        {
                return getRecitationTime();
            }
              if (pos == 12)
        {
                return getLaboratoryInstructor();
            }
              if (pos == 13)
        {
                return getLectureInstructor();
            }
              if (pos == 14)
        {
                return getRecitationInstructor();
            }
              if (pos == 15)
        {
                return new Integer(getStudentCount());
            }
              if (pos == 16)
        {
                return new Integer(getIsTeamTeach());
            }
              return null;
    }
     
    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     *
     * @throws Exception
     */
    public void save() throws Exception
    {
          save(SectionPeer.getMapBuilder()
                .getDatabaseMap().getName());
      }

    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
       * Note: this code is here because the method body is
     * auto-generated conditionally and therefore needs to be
     * in this file instead of in the super class, BaseObject.
       *
     * @param dbName
     * @throws TorqueException
     */
    public void save(String dbName) throws TorqueException
    {
        Connection con = null;
          try
        {
            con = Transaction.begin(dbName);
            save(con);
            Transaction.commit(con);
        }
        catch(TorqueException e)
        {
            Transaction.safeRollback(con);
            throw e;
        }
      }

      /** flag to prevent endless save loop, if this object is referenced
        by another object which falls in this transaction. */
    private boolean alreadyInSave = false;
      /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.  This method
     * is meant to be used as part of a transaction, otherwise use
     * the save() method and the connection details will be handled
     * internally
     *
     * @param con
     * @throws TorqueException
     */
    public void save(Connection con) throws TorqueException
    {
          if (!alreadyInSave)
        {
            alreadyInSave = true;


  
            // If this object has been modified, then save it to the database.
            if (isModified())
            {
                if (isNew())
                {
                    SectionPeer.doInsert((Section) this, con);
                    setNew(false);
                }
                else
                {
                    SectionPeer.doUpdate((Section) this, con);
                }
            }

                      alreadyInSave = false;
        }
      }


                                                          
  
    private final SimpleKey[] pks = new SimpleKey[3];
    private final ComboKey comboPK = new ComboKey(pks);
    
    /**
     * Set the PrimaryKey with an ObjectKey
     *
     * @param key
     */
    public void setPrimaryKey(ObjectKey key) throws TorqueException
    {
        SimpleKey[] keys = (SimpleKey[]) key.getValue();
        SimpleKey tmpKey = null;
                      setSectionId(((NumberKey)keys[0]).intValue());
                        setSectionConfigurationId(((NumberKey)keys[1]).intValue());
                        setSectionName(keys[2].toString());
              }

    /**
     * Set the PrimaryKey using SimpleKeys.
     *
         * @param int sectionId
         * @param int sectionConfigurationId
         * @param String sectionName
         */
    public void setPrimaryKey( int sectionId, int sectionConfigurationId, String sectionName)
        throws TorqueException
    {
            setSectionId(sectionId);
            setSectionConfigurationId(sectionConfigurationId);
            setSectionName(sectionName);
        }

    /**
     * Set the PrimaryKey using a String.
     */
    public void setPrimaryKey(String key) throws TorqueException
    {
        setPrimaryKey(new ComboKey(key));
    }
  
    /**
     * returns an id that differentiates this object from others
     * of its class.
     */
    public ObjectKey getPrimaryKey()
    {
              pks[0] = SimpleKey.keyFor(getSectionId());
                  pks[1] = SimpleKey.keyFor(getSectionConfigurationId());
                  pks[2] = SimpleKey.keyFor(getSectionName());
                  return comboPK;
      }

 

    /**
     * Makes a copy of this object.
     * It creates a new object filling in the simple attributes.
       * It then fills all the association collections and sets the
     * related objects to isNew=true.
       */
      public Section copy() throws TorqueException
    {
        return copyInto(new Section());
    }
  
    protected Section copyInto(Section copyObj) throws TorqueException
    {
          copyObj.setSectionId(sectionId);
          copyObj.setSectionConfigurationId(sectionConfigurationId);
          copyObj.setSectionName(sectionName);
          copyObj.setLaboratoryDay(laboratoryDay);
          copyObj.setLectureDay(lectureDay);
          copyObj.setRecitationDay(recitationDay);
          copyObj.setLaboratoryRoom(laboratoryRoom);
          copyObj.setLectureRoom(lectureRoom);
          copyObj.setRecitationRoom(recitationRoom);
          copyObj.setLaboratoryTime(laboratoryTime);
          copyObj.setLectureTime(lectureTime);
          copyObj.setRecitationTime(recitationTime);
          copyObj.setLaboratoryInstructor(laboratoryInstructor);
          copyObj.setLectureInstructor(lectureInstructor);
          copyObj.setRecitationInstructor(recitationInstructor);
          copyObj.setStudentCount(studentCount);
          copyObj.setIsTeamTeach(isTeamTeach);
  
                    copyObj.setSectionId(0);
                              copyObj.setSectionConfigurationId(0);
                              copyObj.setSectionName((String)null);
                                                                                                
        
        return copyObj;
    }

    /**
     * returns a peer instance associated with this om.  Since Peer classes
     * are not to have any instance attributes, this method returns the
     * same instance for all member of this class. The method could therefore
     * be static, but this would prevent one from overriding the behavior.
     */
    public SectionPeer getPeer()
    {
        return peer;
    }

    public String toString()
    {
        StringBuffer str = new StringBuffer();
        str.append("Section:\n");
        str.append("SectionId = ")
           .append(getSectionId())
           .append("\n");
        str.append("SectionConfigurationId = ")
           .append(getSectionConfigurationId())
           .append("\n");
        str.append("SectionName = ")
           .append(getSectionName())
           .append("\n");
        str.append("LaboratoryDay = ")
           .append(getLaboratoryDay())
           .append("\n");
        str.append("LectureDay = ")
           .append(getLectureDay())
           .append("\n");
        str.append("RecitationDay = ")
           .append(getRecitationDay())
           .append("\n");
        str.append("LaboratoryRoom = ")
           .append(getLaboratoryRoom())
           .append("\n");
        str.append("LectureRoom = ")
           .append(getLectureRoom())
           .append("\n");
        str.append("RecitationRoom = ")
           .append(getRecitationRoom())
           .append("\n");
        str.append("LaboratoryTime = ")
           .append(getLaboratoryTime())
           .append("\n");
        str.append("LectureTime = ")
           .append(getLectureTime())
           .append("\n");
        str.append("RecitationTime = ")
           .append(getRecitationTime())
           .append("\n");
        str.append("LaboratoryInstructor = ")
           .append(getLaboratoryInstructor())
           .append("\n");
        str.append("LectureInstructor = ")
           .append(getLectureInstructor())
           .append("\n");
        str.append("RecitationInstructor = ")
           .append(getRecitationInstructor())
           .append("\n");
        str.append("StudentCount = ")
           .append(getStudentCount())
           .append("\n");
        str.append("IsTeamTeach = ")
           .append(getIsTeamTeach())
           .append("\n");
        return(str.toString());
    }
}
